﻿@model IList<IEnumerable<UserViewModel>>
@{ 
	ViewBag.Title = SiteStrings.SiteSettings_UserManagement_Title;
	ViewData["UsersActive"] = true;
}
<script type="text/javascript">
	$(document).ready(function ()
	{
		// Delete button confirmations
		Roadkill.Web.Setup.bindConfirmDelete();
	});
</script>

@Html.SiteSettingsNavigation()

<div id="manage-users">
	<h1>@SiteStrings.SiteSettings_UserManagement_Admins</h1>
	<p>
		<a href="@Url.Action("AddAdmin", "UserManagement")" class="btn btn-primary btn-success">
			@SiteStrings.SiteSettings_UserManagement_NewAdmin
		</a>
	</p>
	<table class="table table-striped" id="admins-table">
		<thead>
			<tr>
				<th>@SiteStrings.SiteSettings_UserManagement_ColumnHeader_Username</th>
				<th>@SiteStrings.SiteSettings_UserManagement_ColumnHeader_Email</th>
				<th colspan="2"></th>
			</tr>
		</thead>
	@foreach (UserViewModel user in Model[0])
	{
		<tr>
			<td style="width:30%;">@user.ExistingUsername</td>
			<td class="stretch">@user.ExistingEmail</td>
			<td class="edit">@Html.ActionLink(SiteStrings.Navigation_Edit, "EditUser", new { id = user.Id }, new { @class = "btn btn-primary btn-mini" })</td>
		@if (Model[0].Count() > 0 && user.Id.ToString() != RoadkillContext.CurrentUser)
		{
			<td class="delete">@Html.ActionLink(SiteStrings.Navigation_Delete, "DeleteUser", new { id = user.ExistingEmail }, new { @class = "confirm btn btn-danger btn-mini" })</td>
		}
		else
		{
			<td></td>
		}
		</tr>
	}
	</table>
	<br class="clear" />

	<h1>@SiteStrings.SiteSettings_UserManagement_Editors</h1>
	<p>
		<a href="@Url.Action("AddEditor", "UserManagement")" class="btn btn-primary btn-success">
			@SiteStrings.SiteSettings_UserManagement_NewEditor
		</a>
	</p>
	<table class="table table-striped" id="editors-table">
		<thead>
			<tr>
				<th>@SiteStrings.SiteSettings_UserManagement_ColumnHeader_Username</th>
				<th>@SiteStrings.SiteSettings_UserManagement_ColumnHeader_Email</th>
				<th colspan="2"></th>
			</tr>
		</thead>
	@foreach (UserViewModel user in Model[1])
	{
		<tr>
			<td style="width:30%;">@user.ExistingUsername</td>
			<td class="stretch">@user.ExistingEmail</td>
			<td class="edit">@Html.ActionLink(SiteStrings.Navigation_Edit, "EditUser", new { id = user.Id }, new { @class = "btn btn-primary btn-mini" })</td>
			<td class="delete">@Html.ActionLink(SiteStrings.Navigation_Delete, "DeleteUser", new { id = user.ExistingEmail }, new { @class = "confirm btn btn-danger btn-mini" })</td>
		</tr>
	}
	</table>
	<br class="clear" />
</div>